from django import forms
class BootrsapModelForm(forms.ModelForm):
    bootrsap_exitis_forms = []
    #定义一个方法 用于设计插件样式
    def __init__(self,*args,**kwargs):
        # 继承父类UserModelForm方法
        super().__init__( *args, **kwargs )
        # 循环找到所有插件（'name','password','age','account','create_time','gender','deprat'）,添加class样式
        for name,field in self.fields.items():
            # 当name等于bootrsap_exitis_forms时中断循环
            if name in self.bootrsap_exitis_forms:
                continue
            else:
                # 当原字段中含有属性时，保留原属性，没有再添加下面这个属性
                if field.widget.attrs:
                    field.widget.attrs["class"] = "form-control"
                    field.widget.attrs["placeholder"] = field.label
                else:
                    field.widget.attrs = {"class": "form-control",
                                          'placeholder': field.label}

class BootrsapForm(forms.Form):
    bootrsap_exitis_forms=[]
    #定义一个方法 用于设计插件样式
    def __init__(self,*args,**kwargs):
        # 继承父类UserModelForm方法
        super().__init__( *args, **kwargs )
        # 循环找到所有插件（'name','password','age','account','create_time','gender','deprat'）,添加class样式
        for name,field in self.fields.items():
            # 当name等于bootrsap_exitis_forms时中断循环
            if name in self.bootrsap_exitis_forms:
                continue
            else:
                # 当原字段中含有属性时，保留原属性，没有再添加下面这个属性
                if field.widget.attrs:
                    field.widget.attrs["class"] = "form-control"
                    field.widget.attrs["placeholder"] = field.label
                else:
                    field.widget.attrs = {"class": "form-control",
                                          'placeholder': field.label}